﻿using System.Windows.Controls;
using System.Windows;

using MissedMemo.MeatAndCheeseDisc.BusinessLogic;


namespace MissedMemo.MeatAndCheeseDisc.OrderEntry
{
    public partial class viewOrderDetails : UserControl
    {
        public viewOrderDetails()
        {
            InitializeComponent();
        }


        private void btnAddItem_Click( object sender, RoutedEventArgs e )
        {
            Order order = DataContext as Order;

            if( order != null )
            {
                Pizza pizza = new Pizza();

                pizza.ItemType = (PizzaType)comboPizzaType.SelectedValue;
                pizza.Size = (PizzaSize)comboPizzaSize.SelectedValue;

                order.OrderItems.Add( pizza );
            }
        }


        private void btnX_Click( object sender, RoutedEventArgs e )
        {
            Order order = DataContext as Order;

            if( order != null )
            {
                Pizza pizza = ( sender as FrameworkElement ).DataContext as Pizza;

                if( pizza != null )
                {
                    order.OrderItems.Remove( pizza );
                }
            }
        }
    }
}
